package pack1015.fengzhuang;

public class Teacher2 {

    // 属性私有化
    private int age;

    private String name;

    // 每个属性提供两个方法去访问它们（设置｜获取）
    public void setAge(int age) {
        if (age < 22) {
            System.out.println("年龄不符合要求，赋予默认值");
            this.age = 22;
            return;
        }
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String detail() {
        return "我是:" + name + ",今年" + age + "岁";
    }
}